home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1040
- VERSION : 3.1
- OS : DOS
- DATE : October 26, 1992 PAGE : 1/2
-
- TITLE : Creating a .WAV resource and using sndPlaySound().
-
-
-
-
-
-
- QUESTION:
- How to you place a wave file into resource file and play
- the resource with sndPlaySound function?
-
- ANSWER:
- First, let us examine how to place a wave file into a
- resource file.
-
- To place the file(s) into resource file modifying the
- resource file to contain the following line:
-
- {name} {type} "{file name}"
-
- where
- {name} - The name of the resource.
- {type} - Resource type. 'SOUND' is the
- usual custom resource type.
- {file name} - The full path name of the file or
- just the file name if is in the
- same directory as the resource
- file.
-
- The following steps can be used with Resource Workshop:
-
- 1) Resource->New->NewType
- 2) Type in "ID_SOUND" or "ID_WAVE".
- 3) If you type yes for creating a resource id make
- sure you have access to that symbol. For now
- press No.
- 4) Resource->New and choose "SOUND" resource type.
- This will bring up a text editor. Edit the text to
- look similar to the syntax mentioned in the
- section above.
-
-
- NOTE: Wave files usually takes a lot of memory which
- means you might have very large resource files.
-
- Now, let us examine how to access the wave file and play it
- from the application. The following code can be used to load
- and play the resource.
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1040
- VERSION : 3.1
- OS : WIN
- DATE : October 26, 1992 PAGE : 2/2
-
- TITLE : Creating a .WAV resource and using sndPlaySound().
-
-
-
-
- LPCSTR sound; // A pointer to the binary wave file.
-
- hResource = LoadResource( hInst,
- FindResource( hInst,
- MAKEINTRESOURCE(ID_SOUND),
- "SOUND" ) );
-
- sound = ( LPCSTR )LockResource( hResource );
- sndPlaySound( sound, SND_MEMORY );
-
- UnlockResource( hResource );
- FreeResource( hResource );
-
-
- In the code above our resource type is "SOUND" and the resource
- identifier ID_SOUND. We first use FindResource API function to
- find the resource. This function returns a handle to the
- resource. This handle is passed to the LoadResource which
- returns a handle to a copy of the resource in memory. The
- LockResource is next used to get a pointer to the resource. Once
- a pointer is available, the latter can be used in a call to the
- sndPlaySound() function. The second parameter, SND_MEMORY, is
- used to denote that the first parameter is a pointer an in memory
- copy of the wave file.
-
- If you would like to obtain a running sample application using
- sndPlaySound with a resource file you can download the file
- "SOUNDRC.ZIP" from our BBS, CompuServe, BIX, and Genie.
-
- For more information about sndPlaySound and the other API
- function refer to online helps (BCW Reference Guide and
- Multimedia Guide).
-
-
-
- DISCLAIMER: You have the right to use this technical information
- subject to the terms of the No-Nonsense License Statement that
- you received with the Borland product to which this information
- pertains.
-
-
-
-
-
-
-
-
-
-
-